﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Language.Intellisense;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
using LuaLanguageExtension.Parsing;

namespace LuaLanguageExtension.Intellisense
{
    //[Export(typeof(ICompletionSourceProvider))]
    //[Name("Lua Completion Source")]
    //[Order(Before = "default")]
    //[ContentType(Constants.LuaLanguageExtension)]
    internal class CompletionSourceProvider : ICompletionSourceProvider
    {
        [Import]
        internal IObjectModelProviderBroker TokenStreamProviderBroker { get; set; }
        
        public ICompletionSource TryCreateCompletionSource(Microsoft.VisualStudio.Text.ITextBuffer textBuffer)
        {
            if (TokenStreamProviderBroker.IsLua(textBuffer))
                return new CompletionSource(TokenStreamProviderBroker, textBuffer);
            return null;
        }
    }
}
